﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using DBUtility;
using IDAL.RF.QuantityandTime;
using Model;
using System;

namespace DAL.RF.QuantityandTime
{
    public class HighFTest_PRT : IHighFTest_PRT
    {
        #region 静态变量部分
        private const string PARM_TEST_PRODUCTTYPEID = "@ProductTypeID";
        private const string PARM_TEST_STARTTIME = "@starttime";
        private const string PARM_TEST_STOPTIME = "@stoptime";
        #endregion


        protected IList<Time_PRInfo> GetOPRbyDT(string spname, DateTime starttime, DateTime stoptime)
        {
            IList<Time_PRInfo> t_qs = new List<Time_PRInfo>();
            SqlParameter[] testParms = GetDTParameters();
            testParms[0].Value = starttime;
            testParms[1].Value = stoptime;
            using (SqlDataReader rdr = sqlHelper.ExecuteReader(sqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, spname, testParms))
            {
                while (rdr.Read())
                {
                    Time_PRInfo t_q = new Time_PRInfo(rdr.GetValue(0).ToString(), rdr.GetDecimal(1), rdr.GetInt32(2), rdr.GetInt32(3));
                    t_qs.Add(t_q);
                }
            }
            return t_qs;
        }


        public IList<Time_PRInfo> HighFTest_GetOPRbyPID_DT(DateTime starttime, DateTime stoptime)
        {
            return GetOPRbyDT("HighFTest_OPRbyPID_DT", starttime, stoptime);
        }

        public IList<Time_PRInfo> HighFTest_GetPRbyPID_DT(DateTime starttime, DateTime stoptime)
        {
            return GetOPRbyDT("HighFTest_PRbyPID_DT", starttime, stoptime);
        }

        #region 参数部分
        private static SqlParameter[] GetDTParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
                    new SqlParameter(PARM_TEST_STARTTIME, SqlDbType.DateTime, 8),
					new SqlParameter(PARM_TEST_STOPTIME, SqlDbType.DateTime, 8)             
                };
            return parms;
        }
        #endregion
    }
}
